#pragma once
#include "RBTree.h"



template<class K, class V>
class map
{
	struct GetValueOfV
	{
		const K& operator()(const pair<K,V>& x)
		{
			return x.first;
		}
	};

public:
	typedef typename RBTree<K, pair<K, V>, GetValueOfV>::Iterator iterator;
	typedef typename RBTree<K, pair<K, V>, GetValueOfV>::Const_Iterator const_iterator;

	pair<iterator, bool> insert(const pair<K,V>& x)
	{
		return t.Insert(x);
	}
	iterator find(const K& x)
	{
		return t.Find(x);
	}

	iterator begin()
	{
		return t.Begin();
	}

	V& operator[](const K& key)
	{
		pair<iterator,bool> it = t.Insert(make_pair(key,V()));
		return it.first->second;
	}

	iterator end()
	{
		return t.End();
	}

	const_iterator begin() const
	{
		return t.Begin();
	}

	const_iterator end() const
	{
		return t.End();
	}


private:
	RBTree<K, pair<K, V>, GetValueOfV> t;
};